<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定时器</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }

        #box1{
            width: 100px;
            height: 100px;
            background-color: #bfa;
            position: absolute;
            top: 50px;
        }

        #box2{
            width: 100px;
            height: 100px;
            background-color: yellow;
            position: absolute;
            left: 0;
            top: 200px;
        }
        
        #line{
            width: 0px;
            height: 1000px;
            border-left: 1px solid #000;
            position: absolute;
            left: 800px;
            top: 0;
        }
    </style>
    <script type="text/javascript" src="tools.js"></script>
    <script type="text/javascript">
        window.onload=function(){
            var box1=document.getElementById("box1");
            var box2=document.getElementById("box2");

            var btn1=document.getElementById("btn1");
            var btn2=document.getElementById("btn2");
            var btn3=document.getElementById("btn3");
            var btn4=document.getElementById("btn4");


            btn1.onclick=function(){
                move(box1,"left",800,20);
            };

            btn2.onclick=function(){
                move(box1,"left",0,10);
            }

            btn3.onclick=function(){
                move(box2,"left",800,10);
            }

            btn4.onclick=function(){
                move(box2,"width",800,30,function(){
                    alert("helloworld");
                });
            }
        };

        // 创建一个定时器
        // var timer;

        
    </script>
</head>
<body>
    <button id="btn1">点击box1向右移动</button>
    <button id="btn2">点击box1向左移动</button>
    <button id="btn3">点击box2向右移动</button>
    <button id="btn4">测试</button>

    <div id="box1"></div>
    <div id="box2"></div>

    <div id="line"></div>
</body>
</html>